package com.ht.impl.demo;

import com.mxgraph.io.mxCodec;
import com.mxgraph.model.mxCell;
import com.mxgraph.model.mxGeometry;
import com.mxgraph.model.mxGraphModel;
import com.mxgraph.util.mxUtils;

import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 *
 * @author Dong Shufeng
 *         Date: 2010-6-21
 */
public class ModelWriterDemo {
    public static void main(String[] args) {
        //mxGraph g = new mxGraph(new mxGraphModel());
        mxGraphModel model = new mxGraphModel();
        mxCell root = (mxCell) model.createRoot();
        model.setRoot(root);
        mxCell cell = new mxCell("haha", new mxGeometry(50, 50, 100, 100), "shape=ellipse");
        model.add(root.getChildAt(0), cell, 0);
        mxCodec codec = new mxCodec();
        String xml = mxUtils.getXml(codec.encode(model));
        try {
            mxUtils.writeFile(xml, "d:\\test.mxe");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
